package design.singleton.lazy;

/**
 * 静态内部类实现单例模式
 * 懒汉式
 * 线程安全
 * 类加载后调用才初始化对象，Spring默认方式
 * 这种方式是类被装载了，instance 不一定被初始化;只有显式调用getInstance方法才会装载
 */
public class StaticInnerClassSingleton {
    private static class SingletonHolder {
        private static final StaticInnerClassSingleton INSTANCE = new StaticInnerClassSingleton();
    }

    private StaticInnerClassSingleton() {}

    public static final StaticInnerClassSingleton getInstance() {
        return SingletonHolder.INSTANCE;
    }
}
